package com.cskaoyan.wordmemorize.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cskaoyan.wordmemorize.dao.entity.UserPrivilegeUseStatisticsDO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface UserPrivilegeHistoryMapper extends BaseMapper<UserPrivilegeUseStatisticsDO> {


    @Update("UPDATE user_privilege_use_statistics " +
            "SET use_count = use_count + #{increment}, " +
            "updated_time = NOW() " +
            "WHERE user_id = #{userId} AND privilege_code = #{privilegeCode}")
    int incrementUseCount(@Param("userId") Long userId,
                          @Param("privilegeCode") String privilegeCode,
                          @Param("increment") Integer increment);  // 增加使用次数
}
